package com.yiyang.entity;

import lombok.Data;


//统一处理响应的结果实体对象
@Data
public class ResultVO<T>{
    //响应的自定义的状态码
    private Integer code;
    private String message;
    private T data;
    //定义total,用于记录分页的总条数
    private Long total;

    public static <T> ResultVO<T> success(T data){
        ResultVO<T> resultVO=new ResultVO<>();
        resultVO.setCode(Code.SUCCESS);
        resultVO.setMessage("成功");
        resultVO.setData(data);
        return resultVO;
    }
    public static <T> ResultVO<T> success(T data,Long total){
        ResultVO<T> resultVO=new ResultVO<>();
        resultVO.setCode(Code.SUCCESS);
        resultVO.setMessage("成功");
        resultVO.setData(data);
        resultVO.setTotal(total);
        return resultVO;
    }
    public static <T> ResultVO<T> fall(){
        ResultVO<T> resultVO = new ResultVO<>();
        resultVO.setCode(Code.FAIL);
        resultVO.setMessage("失败");
        return resultVO;
    }
}

